package com.chagee.channel.api.bo.lark;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.annotation.JSONField;
import com.chagee.channel.api.bo.lark.StartApprovalBO.JSONArraySerializer;
import java.io.Serializable;
import javax.validation.constraints.NotBlank;
import lombok.Data;
import lombok.experimental.Accessors;

/**
 * @author: chang.jiawei
 * @date: 2024/01/16
 * 发起审批之前
 *{
 *     "approval_code":"C2CAAA90-70D9-3214-906B-B6FFF947F00D",
 *     "user_id":"f7cb567e",
 *     "department_id":"",
 *     "form":"[{\"id\":\"widget16256287451710001\", \"type\": \"number\", \"value\":\"43\"}]"
 * }
 *
 * 发起审批之后
 * {
 *     "instance_code":"12345CA6-97AC-32BB-8231-47C33FFFCCFD",
 *     "user_id":"f7cb567e",
 *     "task_id": "6982332863116876308"
 * }
 */
@Data
@Accessors(chain = true)
public class PreviewApprovalBO implements Serializable {

    private static final long serialVersionUID = -4219032237512345599L;

    @JSONField(name = "approval_code")
    private String approvalCode;

    @JSONField(name = "instance_code")
    private String instanceCode;

    @NotBlank(message = "userId不能为空")
    @JSONField(name = "user_id")
    private String userId;

    /**
     * 发起审批用户部门，如果用户只属于一个部门，可以不填，如果属于多个部门，必须填其中一个部门
     */
    @JSONField(name = "department_id")
    private String departmentId;

    @JSONField(serializeUsing = JSONArraySerializer.class)
    private JSONArray form;

    /**
     * 若审批实例已存在，则传递当前审批任务对应的task_id, 并且user_id需要传task的指派人
     */
    @JSONField(name = "task_id")
    private String taskId;
}
